﻿// -------------------------------------------------------------------------
//    @FileName         :    NFTransGetRole.h
//    @Author           :    gaoyi
//    @Date             :    24-8-28
//    @Email            :    445267987@qq.com
//    @Module           :    NFTransGetRole
//
// -------------------------------------------------------------------------

#pragma once

#include "NFTransAccBase.h"
#include "proto_common_bag.nanopb.h"
#include "proto_common_role.nanopb.h"

namespace proto_ff
{
    class tbRoleDetail;
}

typedef enum
{
    TRANS_GETROLE_STATE_INIT = 0,
    TRANS_GETROLE_GETING_ROLEDETAIL = 2,
    TRANS_GETROLE_GET_ROLE = 3,
    TRANS_GETROLE_INSERTING_ROLEDETAIL = 4,
    TRANS_GETROLE_FINI_OK = 6,
} EN_TRANSGETROLE_STATE;

class NFPlayer;

class NFTransGetRole : public NF_OBJECT_TEMPLATE_MACRO(NFTransGetRole, EOT_TRANS_LOGIC_GET_ROLE, NFTransAccBase)
public:
    NFTransGetRole();

    ~NFTransGetRole() override;

    int CreateInit();
    int ResumeInit();

public:
    int HandleCSMsgReq(const google::protobuf::Message* pCSMsgReq) override;
    int InsertCacheDataRes(int ullId, int iTableId, int iReason, int32_t errCode, google::protobuf::Message* pMessage) override;
    int GetCacheDataRes(int ullId, int iTableId, int iReason, int32_t errCode, google::protobuf::Message* pMessage) override;
    int HandleDispSvrRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId) override;
    int OnHandleGetRoleRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
    int OnTransFinished(int iRunLogicRetCode) override;
    int OnHandleSetRoutingRes(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
public:
    int ProGetRoleDetailReq();
    int ProGetRoleDetailRes(int32_t err_code, google::protobuf::Message* pMessage);
    int ProInsertRoleDetailRes(int32_t err_code, google::protobuf::Message* pMessage);
    int GetRoleDetailRes(proto_ff::tbRoleDetail* pPbCache);
    int InsertRoleDetailRes(proto_ff::tbRoleDetail* pPbCache);

public:
    int SendLoginEndToOnline();
    int OnGetRoleSuccess(NFPlayer* pPlayer, bool iResume);
public:
    int OnHandleRoleMirrorSession(uint32_t nMsgId, const NFDataPackage& packet, uint32_t reqTransId, uint32_t rspTransId);
public:
    char m_sSecData[130];
    RoleOne m_stRoleOne;
    BagPage m_stStorageData;
    int m_loginLockId;
    int m_zoneId;
    uint64_t m_uin;
    int m_targetSvrId;
    int m_iMirrorSessionId;
};
